//
//  ViewController.m
//  QQ音乐
//
//  Created by mafeng on 16/7/19.
//  Copyright © 2016年 mafeng. All rights reserved.
//

#import "ViewController.h"
#import "FXBlurView.h"
#import "Masonry.h"
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    // 背景imageView
    UIImageView *backgroundImageView = [[UIImageView alloc] init];
    [self.view addSubview:backgroundImageView];
    [backgroundImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.mas_equalTo(self.view);
        make.center.mas_equalTo(self.view);
    }];
    backgroundImageView.image = [UIImage imageNamed:@"background"];
    
    // 毛玻璃
    FXBlurView *fxblur = [[FXBlurView alloc] init];
    [backgroundImageView addSubview:fxblur];
    [fxblur mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.bottom.mas_equalTo(0);
    }];
    fxblur.iterations = 3;
    fxblur.blurRadius = 20;
    fxblur.tintColor = [UIColor blackColor];
    
    
    // 中间的CD
    UIView *grayView = [[UIView alloc] init];
    //WithFrame:CGRectMake(55, 100, 300, 300)
    [self.view addSubview:grayView];
    [grayView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.centerY.mas_equalTo(self.view).multipliedBy(0.7);
        make.width.mas_equalTo(300);
        make.height.mas_equalTo(300);
    }];
    grayView.layer.cornerRadius = 150;
    grayView.backgroundColor = [UIColor grayColor];
    grayView.layer.masksToBounds = YES;
    
    
    UIImageView *cdImageView = [[UIImageView alloc] init];
    // WithFrame:CGRectMake(60, 105, 290, 290)
    [self.view addSubview:cdImageView];
    [cdImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.centerY.mas_equalTo(self.view).multipliedBy(0.7);
        make.width.mas_equalTo(290);
        make.height.mas_equalTo(290);
    }];
    cdImageView.image = [UIImage imageNamed:@"background"];
    cdImageView.layer.cornerRadius = 145;
    cdImageView.backgroundColor = [UIColor grayColor];
    cdImageView.layer.masksToBounds = YES;
    
    // 音乐的进度的slider上面的pageControl
    UIPageControl *page = [[UIPageControl alloc] init];
    // WithFrame:CGRectMake(160, 460, 100, 20)
    page.numberOfPages = 3;
    [self.view addSubview:page];
    [page mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.centerY.mas_equalTo(self.view).multipliedBy(1.2);
    }];
    
    // 音乐的进度的slider
    UISlider *musicSlider = [[UISlider alloc] init];
    // WithFrame:CGRectMake(60, 500, 300, 20)
    [self.view addSubview:musicSlider];
    [musicSlider mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(self.view).multipliedBy(0.7);
        make.centerX.mas_equalTo(self.view);
        make.centerY.mas_equalTo(self.view).multipliedBy(1.4);
        
    }];
    [musicSlider setMinimumTrackImage:[UIImage imageNamed:@"player_slider_playback_left"] forState:UIControlStateNormal];
    [musicSlider setMaximumTrackImage:[UIImage imageNamed:@"player_slider_playback_right"] forState:UIControlStateNormal];
    [musicSlider setThumbImage:[UIImage imageNamed:@"player_slider_playback_thumb"] forState:UIControlStateNormal];
    
    
    // slider前面的label
    UILabel *havePlaylabel = [[UILabel alloc] init];
    // WithFrame:CGRectMake(10, 500, 50, 20)
    [self.view addSubview:havePlaylabel];
    [havePlaylabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(self.view).multipliedBy(0.1);
        make.right.mas_equalTo(musicSlider.mas_left).offset(-6);
        make.height.mas_equalTo(20);
        make.centerY.mas_equalTo(self.view).multipliedBy(1.4);
    }];
    havePlaylabel.backgroundColor = [UIColor blackColor];
    
    
    // slider后面的label
    UILabel *allPlaylabel = [[UILabel alloc] init];
    // WithFrame:CGRectMake(360, 500, 50, 20)
    allPlaylabel.backgroundColor = [UIColor blackColor];
    [self.view addSubview:allPlaylabel];
    [allPlaylabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(self.view).multipliedBy(0.1);
        make.left.mas_equalTo(musicSlider.mas_right).offset(6);
        make.height.mas_equalTo(20);
        make.centerY.mas_equalTo(self.view).multipliedBy(1.4);
    }];
    // 播放暂停按钮
    UIButton *playButton = [[UIButton alloc] init];
    // WithFrame:CGRectMake(170, 550, 80, 80)
    [self.view addSubview:playButton];
    [playButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.centerY.mas_equalTo(self.view).multipliedBy(1.6);
        make.width.mas_equalTo(self.view).multipliedBy(0.2);
        make.height.mas_equalTo(80);
        
    }];
    [playButton setImage:[UIImage imageNamed:@"player_btn_pause_normal"] forState:UIControlStateNormal];
    
    
    // 上一首歌曲的按钮
    UIButton *preButton = [[UIButton alloc] init];
    // WithFrame:CGRectMake(80, 560, 50, 50)
    [preButton setImage:[UIImage imageNamed:@"player_btn_pre_normal"] forState:UIControlStateNormal];
    [self.view addSubview:preButton];
    [preButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(playButton);
        make.centerX.equalTo(self.view).multipliedBy(0.5);
        make.width.equalTo(@(60));
        make.height.equalTo(@(60));
    }];
    
    
    
    // 下一首歌曲的按钮
    UIButton *nextButton = [[UIButton alloc] init];
    // WithFrame:CGRectMake(280, 560, 50, 50)
    [nextButton setImage:[UIImage imageNamed:@"player_btn_next_normal"] forState:UIControlStateNormal];
    [self.view addSubview:nextButton];
    [nextButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(playButton);
        make.centerX.equalTo(self.view).multipliedBy(1.5);
        make.width.equalTo(@(60));
        make.height.equalTo(@(60));
    }];
    
    // 喜欢按钮
    UIButton *likeButton = [[UIButton alloc] init];
    // WithFrame:CGRectMake(30, 670, 50, 50)
    [likeButton setImage:[UIImage imageNamed:@"mini_love"] forState:UIControlStateNormal];
    [self.view addSubview:likeButton];
    [likeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.view).multipliedBy(1.9);
        make.centerX.equalTo(self.view).multipliedBy(0.2);
        make.width.equalTo(@50);
        make.height.equalTo(@50);
        
    }];
    
    // 单曲循环button
    UIButton *loopButton = [[UIButton alloc] init];
    // WithFrame:CGRectMake(110, 670, 50, 50)
    [loopButton setImage:[UIImage imageNamed:@"miniplayer_btn_repeatone_highlight"] forState:UIControlStateNormal];
    [self.view addSubview:loopButton];
    [loopButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.view).multipliedBy(1.9);
        make.centerX.equalTo(self.view).multipliedBy(0.6);
        make.width.equalTo(@50);
        make.height.equalTo(@50);
    }];
    
    // 下载按钮
    UIButton *downloadButton = [[UIButton alloc] init];
    // WithFrame:CGRectMake(190, 670, 50, 50)
    [downloadButton setImage:[UIImage imageNamed:@"mini_download"] forState:UIControlStateNormal];
    [self.view addSubview:downloadButton];
    [downloadButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.view).multipliedBy(1.9);
        make.centerX.equalTo(self.view);
        make.width.equalTo(@50);
        make.height.equalTo(@50);
    }];
//
    // 分享按钮
    UIButton *shareButton = [[UIButton alloc] init];
    // WithFrame:CGRectMake(270, 670, 50, 50)
    [shareButton setImage:[UIImage imageNamed:@"player_btn_next_normal"] forState:UIControlStateNormal];
    [self.view addSubview:shareButton];
    [shareButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.view).multipliedBy(1.9);
        make.centerX.equalTo(self.view).multipliedBy(1.4);
        make.width.equalTo(@50);
        make.height.equalTo(@50);
    }];
//
    // 音乐列表按钮
    UIButton *listButton = [[UIButton alloc] init];
    // WithFrame:CGRectMake(350, 670, 50, 50)
    [listButton setImage:[UIImage imageNamed:@"miniplayer_btn_playlist_disable"] forState:UIControlStateNormal];
    [self.view addSubview:listButton];
    [listButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.view).multipliedBy(1.9);
        make.centerX.equalTo(self.view).multipliedBy(1.8);
        make.width.equalTo(@50);
        make.height.equalTo(@50);
    }];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
